var express = require("express");
var router = express.Router();
let con = require("../db");

/* GET home page. */
router.get("/", function(req, res, next) {
  res.render("index", { title: "Express" });
});

//首页 Swiper数据
router.get("/getSwiper", function(req, res, next) {
  let sql = "select * from swiper";
  con.query(sql, function(error, results, filed) {
    res.send({ code: 200, results });
  });
});
//icons数据
router.get("/getIconsList", function(req, res, next) {
  let sql = "select * from icon";
  con.query(sql, function(error, results, filed) {
    res.send({ code: 200, results });
  });
});

//home页的list数据
router.get("/getList", function(req, res, next) {
  let sql = "select * from list";
  con.query(sql, function(error, results, filed) {
    res.send({ code: 200, results });
  });
});
//推荐商品列表数据
router.get("/getRecomList", function(req, res, next) {
  let sql = "select * from recomList";
  con.query(sql, function(error, results, filed) {
    res.send({ code: 200, results });
  });
});
//搜索页面的数据
router.get("/getSearchList", (req, res) => {
  let ress = require("../api/search.json");
  res.send({ code: 200, ress });
});
module.exports = router;
